<!DOCTYPE html>
<html>

<head lang="en">
    <title>找攻略</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/strategyComment.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog/dialog.css">
    <script src="/js/plugins/jrender/jrender.js"></script>
    <link rel="stylesheet" href="/js/plugins/jquery-confirm/css/jquery-confirm.css">
    <script src="/js/plugins/jquery-confirm/js/jquery-confirm.js"></script>
    <script src="/js/plugins/dialog/dialog.min.js"></script>
    <script src="/js/common.js"></script>


</head>

<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="javascript:history.go(-1);">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span>点评详情</span>
        </div>
        <div class="col"></div>
    </div>
</div>

<div class="comment">


    <div class="container ">
        <div class="row">
            <div class="col-2 comment-head">
                <a render-key="list.user.id" render-fun="handleUser" data-id="43">
                    <img class="rounded-circle" render-src="list.user.headImgUrl">
                </a>
                <button class="btn" id="followBtn" render-value="list.user.id"><i class="fa fa-hand-o-right"> </i> 关注</button>
            </div>
            <div class="col">
							<span class="comment-star star">
							</span>

                <span class="comment-date" render-html="list.lastCommentTime"></span>
                <div class="comment-content" render-html="list.content">

                </div>
                <ul class="comment-img" render-loop="list.imgs">
                    <li>
                        <img render-src="list.imgs.url">
                    </li>
                </ul>
                <div class="comment-link">
                    <a render-key="list.stratagy.id" render-fun="handle">
                        <img render-src="list.stratagy.coverUrl"> <span render-html="list.stratagy.title"></span>
                        <i class="fa fa-angle-right fa-2x"></i>
                    </a>
                </div>

            </div>
        </div>
    </div>

    <div class="count d-flex justify-content-between">
        <div class="p-2">评论
            <span>0</span>
        </div>
        <div class="p-2">赞
            <span>0</span>
        </div>
    </div>

</div>

<div class="comment-list">
    快来发表你的评论吧
</div>

<div class="operation">
    <div class="d-flex justify-content-between">
        <div class="p-2"><i class="fa fa-commenting-o addComment"></i> 添加你的评论</div>
        <div class="p-2"><i class="fa fa-star-o"></i> 收藏</div>
    </div>
</div>


</body>
<script>
    var id = getParams().id;
    console.log(id);
    //当前好友关注
    $("#followBtn").click(function () {
        if (getUser()) {
            var attentionId=$(this).val();
            console.log(attentionId);
            $.post("/users/attention",{attentionId:attentionId},function (data) {
                console.log(data);
                $(document).dialog({
                    type : "notice",
                    infoText: data.obj,
                    autoClose: 1500,
                    position: "bottom"
                });
            })
        }else{
            location.href="/login.html";
        }
    });
    //发送ajax请求获取当前攻略的评论
    $.get("/comments/" + id, function (data) {
        $(".container").renderValues({list: data},{
            handle: function (ele, val) {
                ele.href = "/strategyCatalogs.html?id=" + val;
            },
            handleUser: function (ele, val) {
                ele.href = "/userProfiles.html?id=" + val;
            }
        });
        var num = data.star;
        for (var i = 0; i < num; i++) {//拼接实心星星
            $("<i></i>").addClass("fa-star").addClass("fa").appendTo(".star");
        }
        for (var i = 0; i < 5 - num; i++) {//拼接空心星星
            $("<i></i>").addClass("fa-star-o").addClass("fa").appendTo(".star");
        }
    });


    // $(".addComment").click(function () {
    // 	// console.log(id);
    // 	location.href="/comment/addComment.html";
    // });
</script>
</html>